package com.basic.udp;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.DatagramSocket;

public class AskServer {


    public static void main(String[] args) throws IOException {
        //创建一个DatagramSocket,用来发送或者接收数据
        DatagramSocket ds = new DatagramSocket(8888);
        //使用DatagramScoket发送DatagramPacket
        byte[] buf = new byte[1024];
        DatagramPacket dp = new DatagramPacket(buf, buf.length);
        ds.receive(dp);
        System.out.println(new String(buf,0,dp.getLength()));
        System.out.println(dp.getLength());
        System.out.println(dp.getAddress());

        ds.close();
    }
}
